﻿using System;
using hr_1.Model;

namespace hr_1.ViewModel
{
    public class PersonalInfoViewModel:ViewModelBase
    {
        #region Fields

        readonly PersonalInfo _personalInfo = new PersonalInfo();

        #endregion // Fields

        #region Constructor

        public PersonalInfoViewModel() { }

        public PersonalInfoViewModel(PersonalInfo personalInfo)
        {
            if (personalInfo == null)
                throw new ArgumentNullException("personalInfo");

            _personalInfo = personalInfo;
        }

        #endregion // Constructor

        #region PersonalInfo Properties

        public int PersonalInfoId
        {
            get { return _personalInfo.PersonalInfoId; }
        }

        public string HomePhone
        {
            get { return _personalInfo.HomePhone; }
            set
            {
                if (value == _personalInfo.HomePhone)
                    return;
                _personalInfo.HomePhone = value;
                base.OnPropertyChanged("HomePhone");
            }
        }

        public string MobilePhone
        {
            get { return _personalInfo.MobilePhone; }
            set
            {
                if (value == _personalInfo.MobilePhone)
                    return;
                _personalInfo.MobilePhone = value;
                base.OnPropertyChanged("MobilePhone");
            }
        }

        public string Email
        {
            get { return _personalInfo.Email; }
            set
            {
                if (value == _personalInfo.Email)
                    return;
                _personalInfo.Email = value;
                base.OnPropertyChanged("Email");
            }
        }

        public string FamilyStatus
        {
            get { return _personalInfo.FamilyStatus; }
            set
            {
                if (value == _personalInfo.FamilyStatus)
                    return;
                _personalInfo.FamilyStatus = value;
                base.OnPropertyChanged("FamilyStatus");
            }
        }

        public string Address
        {
            get { return _personalInfo.Address; }
            set
            {
                if (value == _personalInfo.Address)
                    return;
                _personalInfo.Address = value;
                base.OnPropertyChanged("Address");
            }
        }

        public string Nationality
        {
            get { return _personalInfo.Nationality; }
            set
            {
                if (value == _personalInfo.Nationality)
                    return;
                _personalInfo.Nationality = value;
                base.OnPropertyChanged("Nationality");
            }
        }
        public string Citizenship
        {
            get { return _personalInfo.Citizenship; }
            set
            {
                if (value == _personalInfo.Citizenship)
                    return;
                _personalInfo.Citizenship = value;
                base.OnPropertyChanged("Citizenship");
            }
        }
        
        #endregion // PersonalDoc Properties

        public void Save()
        {
            _personalInfo.Save();
        }
    }
}
